<html>
<head><meta charset="utf-8"><title>element-wise aggregate initialization · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html">element-wise aggregate initialization</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="136615490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136615490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136615490">(Oct 27 2018 at 17:32)</a>:</h4>
<p>So I was thinking about doing the optimization described in <a href="https://github.com/rust-lang/rust/blob/master/src/librustc_mir/build/expr/as_rvalue.rs#L182" target="_blank" title="https://github.com/rust-lang/rust/blob/master/src/librustc_mir/build/expr/as_rvalue.rs#L182">https://github.com/rust-lang/rust/blob/master/src/librustc_mir/build/expr/as_rvalue.rs#L182</a><br>
My current plan is to basically replace</p>
<div class="codehilite"><pre><span></span><span class="n">_1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">...;</span><span class="w"></span>
<span class="n">_2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">...;</span><span class="w"></span>
<span class="n">_3</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Aggregate</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">x</span>: <span class="nc">_1</span><span class="p">,</span><span class="w"> </span><span class="n">y</span>: <span class="nc">_2</span><span class="w"> </span><span class="p">};</span><span class="w"></span>
</pre></div>


<p>with</p>
<div class="codehilite"><pre><span></span><span class="n">_3</span><span class="p">.</span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">...;</span><span class="w"></span>
<span class="n">_3</span><span class="p">.</span><span class="n">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">...;</span><span class="w"></span>
<span class="n">SetDiscriminant</span><span class="p">(</span><span class="n">_3</span><span class="p">,</span><span class="w"> </span><span class="mi">0</span><span class="p">);</span><span class="w"></span>
</pre></div>


<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> you wrote the original FIXME comment and <span class="user-mention" data-user-id="119009">@eddyb</span> suggested to ask you about potential pitfalls and things to look out for</p>



<a name="136615541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136615541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136615541">(Oct 27 2018 at 17:34)</a>:</h4>
<p>We at some point had an optimisation pass called dis/deaggregation, that was left not entirely finished by an intern 2 years ago?</p>



<a name="136615544"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136615544" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136615544">(Oct 27 2018 at 17:35)</a>:</h4>
<p>maybe 3 now.</p>



<a name="136616028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136616028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136616028">(Oct 27 2018 at 17:53)</a>:</h4>
<p>IIRC eddyb tried to finish it up more recently but there were serious perf regressions and the PR was never pushed over the finish line</p>



<a name="136616068"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136616068" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136616068">(Oct 27 2018 at 17:54)</a>:</h4>
<p>ah no, the PR I was thinking of was merged but didn't eliminates the aggregate rvalues entirely because of perf</p>



<a name="136616069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136616069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136616069">(Oct 27 2018 at 17:54)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/48052" target="_blank" title="https://github.com/rust-lang/rust/pull/48052">https://github.com/rust-lang/rust/pull/48052</a></p>



<a name="136616085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136616085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136616085">(Oct 27 2018 at 17:55)</a>:</h4>
<p>I have a feeling that deagregatting everything will always have the perf impact one way or the other</p>



<a name="136616088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136616088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136616088">(Oct 27 2018 at 17:55)</a>:</h4>
<p>and the earlier it is done, the worse off the impact will end up being</p>



<a name="136616133"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136616133" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136616133">(Oct 27 2018 at 17:56)</a>:</h4>
<p>(because e.g. drop elaboration will have to track many more locals)</p>



<a name="136616318"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136616318" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136616318">(Oct 27 2018 at 18:01)</a>:</h4>
<p>i'm not sure why there would be many more locals? more statements, yes, and that would slow down e.g. data flow analyses, but whether you compute a temporary and then assign it to a projection or whether you put the temporary into an aggregate rvalue to assign the whole struct shouldn't affect the number of locals</p>



<a name="136616370"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136616370" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136616370">(Oct 27 2018 at 18:02)</a>:</h4>
<p>note that this is not quite the same as SROA, we don't need to actually split <code>let t: (T, U);</code> into <code>let (t0, t1): (T, U);</code></p>



<a name="136616384"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136616384" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136616384">(Oct 27 2018 at 18:03)</a>:</h4>
<p>oh, right… I for some reason recalled disagregattor doing SROA</p>



<a name="136616499"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136616499" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136616499">(Oct 27 2018 at 18:06)</a>:</h4>
<p>come to think of it, i'm not sure any more whether more statements would actually have any quadratic behavior. i guess it might depending on how we insert and remove statements in the middle of blocks? but most data flow is linear in the statements. which still doesn't make more statements free (not to mention memory usage) but outside of the "large constant vector that can be created with a single statement today" case it might not be so bad</p>



<a name="136616558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136616558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136616558">(Oct 27 2018 at 18:08)</a>:</h4>
<p>The number of statements would not change with this optimization</p>



<a name="136616560"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136616560" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136616560">(Oct 27 2018 at 18:08)</a>:</h4>
<p>there would simply be fewer locals</p>



<a name="136616581"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136616581" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136616581">(Oct 27 2018 at 18:09)</a>:</h4>
<p>it would if the <code>Aggregate</code> contains constant operands, which currently aren't separate statements</p>



<a name="136616591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136616591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136616591">(Oct 27 2018 at 18:10)</a>:</h4>
<p>e.g. <code>let x = [1, 2, 3, 4, 5];</code> is ca. one statement, with deaggregation it's ca. five</p>



<a name="136616632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136616632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136616632">(Oct 27 2018 at 18:10)</a>:</h4>
<p>right</p>



<a name="136616654"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136616654" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136616654">(Oct 27 2018 at 18:11)</a>:</h4>
<p><span class="user-mention" data-user-id="124289">@rkruppe</span> at least the drop elaboration does not care about what initializes an aggregate. So if yoou have an aggregate that has a billion elements, it won’t have to bother and look at all billion statements that assign the aggregate field by field. IIRC, anyway.</p>



<a name="136616658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136616658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136616658">(Oct 27 2018 at 18:11)</a>:</h4>
<p>but these cases actually have another possibility for optimization: Just generate a single constant instead of ever producing a mir aggregate of constants</p>



<a name="136616665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136616665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136616665">(Oct 27 2018 at 18:11)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@Oli</span> yes i was just typing out something to that effect :)</p>



<a name="136616707"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136616707" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136616707">(Oct 27 2018 at 18:12)</a>:</h4>
<p>It wold be pretty cool to have s/Rvalue::Aggregate/Rvalue::ByteInitializer/</p>



<a name="136616708"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136616708" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136616708">(Oct 27 2018 at 18:12)</a>:</h4>
<p>there are some problems when lifetimes are involved, but I think they are resolveable</p>



<a name="136616713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136616713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136616713">(Oct 27 2018 at 18:12)</a>:</h4>
<p>though <code>[1, 2, 3, 4, 5, ...., runtime_variable, ...]</code> needs either trickery or just remains inefficient (it seems more niche)</p>



<a name="136616722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136616722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136616722">(Oct 27 2018 at 18:13)</a>:</h4>
<p>the trickery being, for example, leaving some elements of the constant undef and overwriting them in a separate statement after the ByteInitializer</p>



<a name="136616724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136616724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136616724">(Oct 27 2018 at 18:13)</a>:</h4>
<p>right</p>



<a name="136622015"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136622015" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136622015">(Oct 27 2018 at 20:56)</a>:</h4>
<p>ok... I found a slightly unfun situation: <code>x[i] = (x[j].0, 42)</code> can't be converted to <code>x[i].0 = x[j].0; x[i].1 = 42;</code> because for index ops going through IndexMut that would evaluate <code>index_mut</code> twice</p>
<p>we also can't do <code>let a = &amp;mut x[i]; a.0 = x[j].0; a.1 = 42;</code> because then borrowck throws a fit</p>



<a name="136622223"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136622223" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136622223">(Oct 27 2018 at 21:03)</a>:</h4>
<p>Ah, I'm in the wrong code anyway. It'll work itself out automatically if I get <code>x = [(4, 5), (1, 2)];</code> to be <code>x[0].0 = 4; x[0].1 = 5; x[1].0 = 1; x[1].1 = 2;</code></p>



<a name="136622795"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136622795" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136622795">(Oct 27 2018 at 21:22)</a>:</h4>
<p>So I think I know how to do this: partially evaluate aggregate initializers so that <code>x[j].0</code> becomes <code>_X</code> if it's not just a projection, then partially evaluate the lhs of the original assignment so we get <code>let a = &amp;mut X</code> if anything other than projections are involved. Then generate all the assignments.</p>
<p>This translates to: Evaluate the rhs to a tree of aggregate initializers of <code>Operand</code>s. Evaluate the lhs to a <code>Place</code>. Visit the aggregate initializer tree recursively, building up the <code>Place</code> to the concrete value as you go in, and popping projections as you go out.</p>



<a name="136630738"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136630738" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136630738">(Oct 28 2018 at 01:39)</a>:</h4>
<p>The previous sentence is not right. It should be <code>Rvalue</code> not <code>Operand</code></p>



<a name="136766260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136766260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136766260">(Oct 30 2018 at 10:04)</a>:</h4>
<p>Ok... I ran into a few problems with this. Most notably I'm now hitting the fact that the 2018 edition forbids <code>let mut s; s.x = Val;</code></p>



<a name="136771837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136771837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136771837">(Oct 30 2018 at 12:08)</a>:</h4>
<p>is this a problem? I can point you at the lang team discussion of the matter</p>



<a name="136771858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136771858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136771858">(Oct 30 2018 at 12:08)</a>:</h4>
<p>oh I see, you're doing it as a MIR transformation that runs <em>before</em> <code>rustc_mir::borrow_check</code>?</p>



<a name="136771877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136771877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136771877">(Oct 30 2018 at 12:09)</a>:</h4>
<p>We can probably easily add a feature flag to let you write that code again. There's an RFC being drafted to describe the scenarios where we would start allowing it again.</p>



<a name="136772047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136772047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136772047">(Oct 30 2018 at 12:12)</a>:</h4>
<p>I just found the RFC draft independently :D <a href="https://github.com/Centril/rfcs/pull/16" target="_blank" title="https://github.com/Centril/rfcs/pull/16">https://github.com/Centril/rfcs/pull/16</a></p>



<a name="136772056"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136772056" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136772056">(Oct 30 2018 at 12:12)</a>:</h4>
<p>Well... a feature flag does make sense. I should probably hide my changes behind one for sanity's sake</p>



<a name="136772070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136772070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136772070">(Oct 30 2018 at 12:13)</a>:</h4>
<p>I'm not even doing a MIR transformation, but changing the way MIR is generated</p>



<a name="136772086"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136772086" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136772086">(Oct 30 2018 at 12:13)</a>:</h4>
<p>deaggregation as a MIR pass is too expensive as proven by our existing deaggregation MIR pass</p>



<a name="136781778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136781778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136781778">(Oct 30 2018 at 14:55)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@Oli</span> I do not think you should change how MIR is generated, but rather I would expect to transform this after the fact as an optimization.</p>



<a name="136781804"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136781804" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136781804">(Oct 30 2018 at 14:55)</a>:</h4>
<p>Otherwise, we're going to need some way to signal that the aggregate is "complete", no? That was the reason we kept it as is until now -- i.e., when do we know that the destructor should run.</p>



<a name="136781808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136781808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136781808">(Oct 30 2018 at 14:55)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> eddyb tried that and we do have a disaggregator</p>



<a name="136781857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136781857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136781857">(Oct 30 2018 at 14:56)</a>:</h4>
<p>What is the motivation here?</p>



<a name="136781859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136781859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136781859">(Oct 30 2018 at 14:56)</a>:</h4>
<p>but it's very inefficient to do so after the fact</p>



<a name="136781871"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136781871" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136781871">(Oct 30 2018 at 14:56)</a>:</h4>
<p>my motivation is const eval performance, so disaggregator would be fine</p>



<a name="136781873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136781873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136781873">(Oct 30 2018 at 14:56)</a>:</h4>
<p>It seems like we're accumulating a few places where we'd like to update MIR</p>



<a name="136781875"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136781875" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136781875">(Oct 30 2018 at 14:56)</a>:</h4>
<p>but now my motivation has become getting rid of <code>Rvalue::Aggregate</code></p>



<a name="136781883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136781883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136781883">(Oct 30 2018 at 14:56)</a>:</h4>
<p>basically where there is tension between the needs of the borrow check (which wants something closer to surface level syntax) and optimizations (which maybe doesn't)</p>



<a name="136781900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136781900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136781900">(Oct 30 2018 at 14:57)</a>:</h4>
<p>I feel pretty wary of making this change at this time</p>



<a name="136781906"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136781906" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136781906">(Oct 30 2018 at 14:57)</a>:</h4>
<p>particularly without some sort of write-up</p>



<a name="136781911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136781911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136781911">(Oct 30 2018 at 14:57)</a>:</h4>
<blockquote>
<p>Otherwise, we're going to need some way to signal that the aggregate is "complete", no? That was the reason we kept it as is until now -- i.e., when do we know that the destructor should run.</p>
</blockquote>
<p>I am currently using  <code>SetDiscriminant</code> for that, which is what the disaggregator MIR pass also does</p>



<a name="136781916"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136781916" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136781916">(Oct 30 2018 at 14:57)</a>:</h4>
<p>i.e., we are in the midst of trying to ship a new borrow checker based on the MIR :)</p>



<a name="136781932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136781932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136781932">(Oct 30 2018 at 14:57)</a>:</h4>
<p>I'm fine with delaying this, but I also do have an impl behind a feature gate ;)</p>



<a name="136781993"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136781993" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136781993">(Oct 30 2018 at 14:58)</a>:</h4>
<p>well, one that doesn't work :)</p>



<a name="136781999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136781999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136781999">(Oct 30 2018 at 14:58)</a>:</h4>
<p>i.e., it breaks in Rust 2018</p>



<a name="136782003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782003">(Oct 30 2018 at 14:58)</a>:</h4>
<p>everywhere where mir borrowck <code>bug!</code>ed out, I assert that the feature gate is active and then do a different change</p>



<a name="136782008"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782008" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782008">(Oct 30 2018 at 14:58)</a>:</h4>
<p>because it's not been integrated properly with the mir borrowck</p>



<a name="136782014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782014">(Oct 30 2018 at 14:58)</a>:</h4>
<p>oh...</p>



<a name="136782022"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782022" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782022">(Oct 30 2018 at 14:58)</a>:</h4>
<p>that explains why my tests pass :D</p>



<a name="136782037"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782037" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782037">(Oct 30 2018 at 14:58)</a>:</h4>
<p>(at least if I understood you properly)</p>



<a name="136782047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782047">(Oct 30 2018 at 14:59)</a>:</h4>
<p>you did, and you're right</p>



<a name="136782056"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782056" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782056">(Oct 30 2018 at 14:59)</a>:</h4>
<p>(that said, I'm not opposed to the overall plan)</p>



<a name="136782058"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782058" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782058">(Oct 30 2018 at 14:59)</a>:</h4>
<p>2018 edition fails hard on this</p>



<a name="136782066"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782066" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782066">(Oct 30 2018 at 14:59)</a>:</h4>
<p>are you fine with me doing this behind a feature gate?</p>



<a name="136782072"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782072" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782072">(Oct 30 2018 at 14:59)</a>:</h4>
<p>hmm</p>



<a name="136782074"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782074" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782074">(Oct 30 2018 at 14:59)</a>:</h4>
<p>no, I am :)</p>



<a name="136782085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782085">(Oct 30 2018 at 14:59)</a>:</h4>
<p>but I am not opposed to you doing it "properly" :P</p>



<a name="136782091"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782091" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782091">(Oct 30 2018 at 14:59)</a>:</h4>
<p>tbh I'm not sure that I'm <em>opposed</em> to anything</p>



<a name="136782097"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782097" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782097">(Oct 30 2018 at 14:59)</a>:</h4>
<p>huh?</p>



<a name="136782141"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782141" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782141">(Oct 30 2018 at 15:00)</a>:</h4>
<p>"properly"?</p>



<a name="136782158"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782158" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782158">(Oct 30 2018 at 15:00)</a>:</h4>
<p>I don't understand why a feature gate makes sense</p>



<a name="136782168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782168">(Oct 30 2018 at 15:00)</a>:</h4>
<p>this is not something end-users of Rust should be able to observe</p>



<a name="136782175"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782175" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782175">(Oct 30 2018 at 15:00)</a>:</h4>
<p>it sounds like you want a feature gate because you want to land a PR that doesn't fully work, I guess? That might be ok</p>



<a name="136782180"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782180" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782180">(Oct 30 2018 at 15:00)</a>:</h4>
<p>but I'd prefer to do that with a broader plan in place for how to finish the work</p>



<a name="136782198"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782198" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782198">(Oct 30 2018 at 15:01)</a>:</h4>
<p>the issue is that we need to allow partially initializing structs, which is forbidden in 2018</p>



<a name="136782211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782211">(Oct 30 2018 at 15:01)</a>:</h4>
<p>(it seems like a "revised MIR" might be a good Rust All Hands discussion topic)</p>



<a name="136782221"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782221" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782221">(Oct 30 2018 at 15:01)</a>:</h4>
<p>yes, though the intention was to eventually support it</p>



<a name="136782227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782227">(Oct 30 2018 at 15:01)</a>:</h4>
<p>jup, so I'd bind these two things together</p>



<a name="136782232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782232">(Oct 30 2018 at 15:01)</a>:</h4>
<p>I see, and the feature gate would be for <em>that</em></p>



<a name="136782237"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782237" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782237">(Oct 30 2018 at 15:02)</a>:</h4>
<p>I believe @centril is working on an RFC on that topic</p>



<a name="136782280"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782280" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782280">(Oct 30 2018 at 15:02)</a>:</h4>
<p>that said, I think the two things are sort of independent</p>



<a name="136782282"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782282" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782282">(Oct 30 2018 at 15:02)</a>:</h4>
<p>they are, (linked above)</p>



<a name="136782286"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782286" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782286">(Oct 30 2018 at 15:02)</a>:</h4>
<p>or should be</p>



<a name="136782287"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782287" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782287">(Oct 30 2018 at 15:02)</a>:</h4>
<p>they are, but without the latter I can't do the former</p>



<a name="136782295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782295">(Oct 30 2018 at 15:02)</a>:</h4>
<p>I'd need a lot of weird workarounds</p>



<a name="136782306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782306">(Oct 30 2018 at 15:02)</a>:</h4>
<p>how do you plan to deal with things like <code>let x = Foo { .. }</code> where <code>Foo</code> has a <code>Drop</code> and hence is not permitted to be partially initialized?</p>



<a name="136782331"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782331" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782331">(Oct 30 2018 at 15:03)</a>:</h4>
<p>hmm... good point...</p>



<a name="136782338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782338">(Oct 30 2018 at 15:03)</a>:</h4>
<p>I skipped drop types so far</p>



<a name="136782343"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782343" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782343">(Oct 30 2018 at 15:03)</a>:</h4>
<p>ok, so these two things are independent</p>



<a name="136782404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782404">(Oct 30 2018 at 15:04)</a>:</h4>
<p>basically if I make drop type element wise intialization work correctly and separately from user element wise initialization, everything should be fine</p>



<a name="136782434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782434">(Oct 30 2018 at 15:05)</a>:</h4>
<p>(one step back: you mentioned that the "deaggregator" was "good enough" to solve some const eval perf problems?)</p>



<a name="136782495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782495">(Oct 30 2018 at 15:06)</a>:</h4>
<p>This necessitates a form of "initialization" similar to <code>mem::uninitialized</code>, but only available to MIR, and only if the expression it's coming from an adt/tuple/array init-expression</p>



<a name="136782496"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782496" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782496">(Oct 30 2018 at 15:06)</a>:</h4>
<p>right</p>



<a name="136782514"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782514" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782514">(Oct 30 2018 at 15:07)</a>:</h4>
<p>const evaluating large arrays is problematic, because we get a local for each element if the element type is complex, and then copy all those locals in one expression into the destination array local</p>



<a name="136782530"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782530" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782530">(Oct 30 2018 at 15:07)</a>:</h4>
<p>yes; same problem of course arises in our codegen</p>



<a name="136782537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782537">(Oct 30 2018 at 15:07)</a>:</h4>
<p>if we just wrote the elements into the array each by itself we'd be saving ourselves quite a few assignments and conversions</p>



<a name="136782586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782586">(Oct 30 2018 at 15:08)</a>:</h4>
<p>(const eval conversions between immediates like fat pointers or ints and their memory representations is expensive)</p>



<a name="136782641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136782641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136782641">(Oct 30 2018 at 15:09)</a>:</h4>
<p>current state of my experiments: <a href="https://gist.github.com/oli-obk/41cc65f0808b63d714ef2d74578f9f6c" target="_blank" title="https://gist.github.com/oli-obk/41cc65f0808b63d714ef2d74578f9f6c">https://gist.github.com/oli-obk/41cc65f0808b63d714ef2d74578f9f6c</a></p>



<a name="136783004"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136783004" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136783004">(Oct 30 2018 at 15:15)</a>:</h4>
<p>OK -- I have to run -- I think the TL;DR is that I definitely want to see improvements here, I just want to have a plan for how it should work in all parts of the compiler. In my ideal world, I think, we'd document this by a PR to rustc-guide that describes the new design (and of course rustc-guide would have enough material that this makes sense). I'm not sure how much docs we have for MIR in the rustc-guide, not enough I imagine to really have it be a "sufficiently precise spec" for this purpose.</p>



<a name="136783027"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136783027" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136783027">(Oct 30 2018 at 15:16)</a>:</h4>
<p>I think <em>maybe</em> it'd be <em>nice</em> if -- perhaps via <code>SetDiscriminant</code>? -- we always generated the same sort of MIR for <code>Foo { .. }</code></p>



<a name="136783069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136783069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136783069">(Oct 30 2018 at 15:16)</a>:</h4>
<p>and the borrow check knew the difference between <code>Drop</code> etc</p>



<a name="136783077"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136783077" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136783077">(Oct 30 2018 at 15:16)</a>:</h4>
<p>but maybe that's not worth it, and we should keep the <code>Aggregate</code> but just not always use it</p>



<a name="136783080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136783080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136783080">(Oct 30 2018 at 15:16)</a>:</h4>
<p>and then lower the remaining uses away</p>



<a name="136783099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136783099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136783099">(Oct 30 2018 at 15:16)</a>:</h4>
<p>I can't really decide if that would actually be nice</p>



<a name="136783509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136783509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136783509">(Oct 30 2018 at 15:21)</a>:</h4>
<p>I'll write something up. I guess first I'll have to do a writeup for <code>HAIR</code> though. The crickets are very loud in <a href="https://rust-lang-nursery.github.io/rustc-guide/mir/construction.html" target="_blank" title="https://rust-lang-nursery.github.io/rustc-guide/mir/construction.html">https://rust-lang-nursery.github.io/rustc-guide/mir/construction.html</a></p>



<a name="136783598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136783598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136783598">(Oct 30 2018 at 15:22)</a>:</h4>
<p>Yes, HAIR specifically has been on my list to try and start documenting</p>



<a name="136783610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136783610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136783610">(Oct 30 2018 at 15:22)</a>:</h4>
<p>I am thinking more and more about this idea of a rustc-guide WG</p>



<a name="136783644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136783644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136783644">(Oct 30 2018 at 15:23)</a>:</h4>
<p>particularly if we are able to use the rustc-guide as a way to talk about design-level discussion? maybe that's a nutty idea</p>



<a name="136783656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136783656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136783656">(Oct 30 2018 at 15:23)</a>:</h4>
<p>I am trying to pursue that path with the trait work: document the intended design,</p>



<a name="136783657"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136783657" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136783657">(Oct 30 2018 at 15:23)</a>:</h4>
<p>implement,</p>



<a name="136783663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136783663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136783663">(Oct 30 2018 at 15:23)</a>:</h4>
<p>and then adjust the docs</p>



<a name="136783664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136783664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136783664">(Oct 30 2018 at 15:23)</a>:</h4>
<p>I won't lie though, it's hard</p>



<a name="136783667"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136783667" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136783667">(Oct 30 2018 at 15:23)</a>:</h4>
<p>takes time :)</p>



<a name="136783726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136783726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136783726">(Oct 30 2018 at 15:24)</a>:</h4>
<p>I'll start documenting how mir building works, since it's fresh on my mind</p>



<a name="136786617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136786617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136786617">(Oct 30 2018 at 16:07)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@Oli</span> I do not believe disaggregation being run as a pass as the core cause of the slowness for the disaggregator pass. Rather I think it is all on us not having an efficient way to update MIR.</p>



<a name="136786805"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136786805" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136786805">(Oct 30 2018 at 16:10)</a>:</h4>
<p>I do however think getting rid of Rvalue::Aggregate entirely could be a nice simplification of the IR, if it doesn't force significant extra complexity on borrowck/drop elaboration/etc.</p>



<a name="136786807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136786807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136786807">(Oct 30 2018 at 16:10)</a>:</h4>
<p>even so, the changes required for doing this during MIR generation are minimal</p>



<a name="136786826"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136786826" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136786826">(Oct 30 2018 at 16:11)</a>:</h4>
<p>we do need the changes to all the other passes anyway when/if we get element-wise initialization in user space</p>



<a name="136786842"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136786842" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136786842">(Oct 30 2018 at 16:11)</a>:</h4>
<p>good point</p>



<a name="136786963"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136786963" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136786963">(Oct 30 2018 at 16:12)</a>:</h4>
<p>I am mainly concerned about <code>[1, 2, 3]</code> as an <code>Rvalue::Aggregate</code> of constants becoming 3 statements</p>



<a name="136786988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136786988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136786988">(Oct 30 2018 at 16:12)</a>:</h4>
<p>but I believe we can address this by generating the appropriate constant on the fly (if we consider that to be a problem at all)</p>



<a name="136791243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/element-wise%20aggregate%20initialization/near/136791243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/element-wise.20aggregate.20initialization.html#136791243">(Oct 30 2018 at 17:12)</a>:</h4>
<blockquote>
<p><span class="user-mention" data-user-id="124288">@Oli</span> I do not believe disaggregation being run as a pass as the core cause of the slowness for the disaggregator pass. Rather I think it is all on us not having an efficient way to update MIR.</p>
</blockquote>
<p>I just added this to my <a href="https://paper.dropbox.com/doc/Compiler-Team-Planning-Rust-All-Hands-2018--AQmd~UZkigjTaNOOhZO2pXhlAg-EiyRtIBW1KxYI6nZeTKjt#:uid=823892722052589599911454&amp;h2=Possible-discussion-topics" target="_blank" title="https://paper.dropbox.com/doc/Compiler-Team-Planning-Rust-All-Hands-2018--AQmd~UZkigjTaNOOhZO2pXhlAg-EiyRtIBW1KxYI6nZeTKjt#:uid=823892722052589599911454&amp;h2=Possible-discussion-topics">list of all hands topics</a> -- see the MIR 2.0 bullet point :)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>